package com.pmc.dwa.common.utils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 适用于和JqueryUI DataGrid交互时，获取List集合数据。
 * @author 王坤
 * @date 2011-12-15
 */
public class JsonGrid<T extends Object> implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private long total;    //总条数
	private List<T> rows;  //当前显示数据列表
	
	public JsonGrid(){}

	public JsonGrid(long total,List<T> rows){
		this.rows = rows==null ? new ArrayList<T>() : rows;
		this.total = total;
	}
	
	public JsonGrid(PaginationSupport<T> pager){
		this.total = pager.getTotalCount();
		this.rows = pager.getItems()==null ? new ArrayList<T>() :  pager.getItems();
	}
	
	/**
	 * @return the rows
	 */
	public List<T> getRows() {
		return rows;
	}
	/**
	 * @param rows the rows to set
	 */
	public void setRows(List<T> rows) {
		this.rows = rows;
	}

	/**
	 * @return the total
	 */
	public long getTotal() {
		return total;
	}

	/**
	 * @param total the total to set
	 */
	public void setTotal(long total) {
		this.total = total;
	}
}